#ifndef SESSIONITEM_H
#define SESSIONITEM_H

#include <QObject>
#include <functional>
#include "tcpsession.h"

class SessionItem : public QObject
{
    Q_OBJECT
signals:
    void SignalRead(const QString&, const QByteArray&);          //TcpSocket signal to itemSlotRead
    void SignalDisconnected(const QString&);
    void SignalConnected();     //TcpSocket connected signal to ItemSignalConnected

public:
    SessionItem(std::shared_ptr<TcpSession> &session);
    ~SessionItem();

public:
    void Write(const char* buf, size_t buf_size);
    void Write(const QByteArray&);
    void Connect(const QString &addr, quint16 port);

    QString& GetSessionStr();

private slots:
    void SlotRead(const QByteArray&);
    void SlotDisconnect();

private:
    std::shared_ptr<TcpSession> m_Session;
    QString m_IpPortStr;
};

#endif // SESSIONITEM_H
